#include <iostream>

int main()
{
	int n, m;
	std::cin >> n >> m;
	if (n == 1) {
		std::cout << "1\n";
		return 0;
	}
	if (m - 1 >= n - m)
		std::cout << m - 1;
	else
		std::cout << m + 1;
}
